
#include "CommonEntity.h"

#include <SDL2/SDL_opengl.h>

namespace ALittle
{

CommonEntity::CommonEntity()
: m_scale_x(1), m_scale_y(1), m_scale_z(1)
, m_rotate_x(0), m_rotate_y(0), m_rotate_z(0)
, m_trans_x(0), m_trans_y(0), m_trans_z(0)
, m_visible(true)
{ }

CommonEntity::~CommonEntity()
{ }

void CommonEntity::SetVisible(bool visible)
{
	m_visible = visible;
}

void CommonEntity::Render()
{
	if (!m_visible) return;

	glPushMatrix();
	glTranslatef(m_trans_x, m_trans_y, m_trans_z);
	if (m_rotate_x != 0.0f) glRotatef(m_rotate_x, 1.0f, 0.0f, 0.0f);
	if (m_rotate_y != 0.0f) glRotatef(m_rotate_y, 0.0f, 1.0f, 0.0f);
	if (m_rotate_z != 0.0f) glRotatef(m_rotate_z, 0.0f, 0.0f, 1.0f);
	glScalef(m_scale_x, m_scale_y, m_scale_z);
	Draw();
	glPopMatrix();
}

void CommonEntity::Draw()
{ }

void CommonEntity::SetTransX(float x)
{
	m_trans_x = x;
}
void CommonEntity::SetTransY(float y)
{
	m_trans_y = y;
}
void CommonEntity::SetTransZ(float z)
{
	m_trans_z = z;
}

void CommonEntity::SetScaleX(float x)
{
	m_scale_x = x;
}
void CommonEntity::SetScaleY(float y)
{
	m_scale_y = y;
}
void CommonEntity::SetScaleZ(float z)
{
	m_scale_y = z;
}

void CommonEntity::SetRotateX(float x)
{
	m_rotate_x = x;
}
void CommonEntity::SetRotateY(float y)
{
	m_rotate_y = y;
}
void CommonEntity::SetRotateZ(float z)
{
	m_rotate_z = z;
}

} // ALittle
